<?php

namespace app\web\controller;


use think\Cache;

class Clearcache extends Base
{
    public function clearcache()
    {
        global $_P, $_G;
        // 清除所有缓存
        Cache::clear();
        cache_delete(MODULE_NAME . 'version');
        cache_delete(MODULE_NAME . 'wxapp_version');
        $_P['referer'] = empty($_P['referer']) ? $_SERVER['HTTP_REFERER'] : $_P['referer'];
        $count = intval($_P['count']) + 1;
        if ($count < 10) {
            $url = createWebUrl('clearcache', array('count' => $count, 'themeid' => $_P['themeid'], 'referer' => $_P['referer']));
            echo "<script language='javascript' type='text/javascript'>";
            echo "window.location.href='$url';";
            echo "</script>";
            exit;
        } else {
            $url = $_P['referer'];
            return_tips('清空缓存成功', $url, 'success');
        }
    }
}